package com.brt.museum.vo;

import com.brt.museum.bean.auth.Permission;
import com.brt.museum.bean.auth.Role;

/**
 * @author 王贵源
 * @email kerbores@dgj.com
 *
 *        create at 2015年10月20日 上午9:47:15
 */
public class Consts {

	public static final int PAGESIZE = 15;

	public static class SessionKeys {
		public static final String SESSION_USER_KEY = "BRT_USER";
		public static final String SESSION_MENU_KEY = "BRT_MENU";
	}

	/**
	 * 内置角色
	 * 
	 * @author wkipy
	 *
	 */
	public static enum InstalledRoles {
		/**
		 * 超级管理员
		 */
		ADMIN(999, "admin", "最高权限管理员");

		private int id;
		private String name;
		private String desc;

		public Role toRole() {
			Role role = new Role();
			role.setId(id);
			role.setDescription(desc);
			role.setName(name);
			role.setInstalled(true);
			return role;
		}

		/**
		 * @return the id
		 */
		public int getId() {
			return id;
		}

		/**
		 * @param id
		 *            the id to set
		 */
		public void setId(int id) {
			this.id = id;
		}

		/**
		 * @return the name
		 */
		public String getName() {
			return name;
		}

		/**
		 * @param name
		 *            the name to set
		 */
		public void setName(String name) {
			this.name = name;
		}

		/**
		 * @return the desc
		 */
		public String getDesc() {
			return desc;
		}

		/**
		 * @param desc
		 *            the desc to set
		 */
		public void setDesc(String desc) {
			this.desc = desc;
		}

		/**
		 * @param id
		 * @param name
		 */
		private InstalledRoles(int id, String name, String desc) {
			this.id = id;
			this.name = name;
			this.desc = desc;
		}

	}

	/**
	 * 权限分组,菜单分组
	 * 
	 * @author wkipy
	 *
	 */
	public static enum PermissionGroup {
		/**
		 * 用户管理
		 */
		USER_ADMIN("用户管理", "fa fa-user", 1, "user");

		/*
		 * 名称
		 */
		private String name;
		/**
		 * Icon
		 */
		private String icon;
		/**
		 * 顺序
		 */
		private int index;

		private String nameSpace;

		private PermissionGroup(String name, String icon, int index, String nameSpace) {
			this.name = name;
			this.icon = icon;
			this.index = index;
			this.nameSpace = nameSpace;
		}

		public String getNameSpace() {
			return nameSpace;
		}

		public void setNameSpace(String nameSpace) {
			this.nameSpace = nameSpace;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public String getIcon() {
			return icon;
		}

		public void setIcon(String icon) {
			this.icon = icon;
		}

		public int getIndex() {
			return index;
		}

		public void setIndex(int index) {
			this.index = index;
		}

	}

	/**
	 * 内置权限
	 * 
	 * @author wkipy
	 *
	 */
	public static enum InstalledPermission {
		/**
		 * 用户列表
		 */
		USER_LIST(999, "用户列表", "用户列表", true, 0, PermissionGroup.USER_ADMIN, "/user/list", "user_list"),
		/**
		 * 角色列表
		 */
		ROLE_LIST(998, "角色列表", "角色列表", true, 0, PermissionGroup.USER_ADMIN, "/role/list", "role_list"),
		/**
		 * 权限列表
		 */
		PERMISSION_LIST(997, "权限列表", "权限列表", true, 0, PermissionGroup.USER_ADMIN, "/permission/list", "permission_list");

		private int id;
		private String name;
		private String desc;
		private boolean menu;
		private int need;
		private PermissionGroup menuGroup;
		private String url;
		private String key;

		private InstalledPermission(int id, String name, String desc, boolean menu, int need, PermissionGroup menuGroup, String url, String key) {
			this.id = id;
			this.name = name;
			this.desc = desc;
			this.menu = menu;
			this.need = need;
			this.menuGroup = menuGroup;
			this.url = url;
			this.key = key;
		}

		public int getId() {
			return id;
		}

		public void setId(int id) {
			this.id = id;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public String getDesc() {
			return desc;
		}

		public void setDesc(String desc) {
			this.desc = desc;
		}

		public boolean isMenu() {
			return menu;
		}

		public void setMenu(boolean menu) {
			this.menu = menu;
		}

		public int getNeed() {
			return need;
		}

		public void setNeed(int need) {
			this.need = need;
		}

		public PermissionGroup getMenuGroup() {
			return menuGroup;
		}

		public void setMenuGroup(PermissionGroup menuGroup) {
			this.menuGroup = menuGroup;
		}

		public String getUrl() {
			return url;
		}

		public void setUrl(String url) {
			this.url = url;
		}

		public String getKey() {
			return key;
		}

		public void setKey(String key) {
			this.key = key;
		}

		public Permission toPermission() {
			Permission permission = new Permission();
			permission.setDescription(desc);
			permission.setInstalled(true);
			permission.setName(name);
			permission.setMenuGroup(menuGroup);
			permission.setNeedPermission(need);
			permission.setMenu(menu);
			permission.setUrl(url);
			permission.setHilightKey(key);
			return permission;
		}
	}
}
